Skip to content

Support constants in custom storage layout expression #15944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

matheusaaguiar
Copy link
Collaborator

part of #15727.

@matheusaaguiar matheusaaguiar self-assigned this Mar 15, 2025
@matheusaaguiar matheusaaguiar force-pushed the allowConstantsCustomStorageLayout branch 2 times, most recently from 944dc30 to 059349f Compare March 25, 2025 23:27
@matheusaaguiar matheusaaguiar force-pushed the allowConstantsCustomStorageLayout branch from 4aae044 to 00ee32e Compare March 27, 2025 02:03
"The base slot of the storage layout must evaluate to an integer."
);
return;
if (integerType->isSigned())
Copy link
Collaborator Author

@matheusaaguiar matheusaaguiar Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be removed from here and then replace the assert in line 173 as suggested in a previous PR #15528 (comment)

@matheusaaguiar matheusaaguiar marked this pull request as ready for review March 27, 2025 02:20
@zaqk
Copy link

zaqk commented Apr 4, 2025

thank you for supporting constants! this is a huge composability unlock!

@zaqk
Copy link

zaqk commented Apr 4, 2025

Would this also apply to immutables?

@matheusaaguiar
Copy link
Collaborator Author

Would this also apply to immutables?

No, this only targets constants. Immutables are a little bit different and demand a different handling.

@cameel
Copy link
Member

cameel commented Apr 11, 2025

We can't really support immutables here, because the layout must already be defined at creation time (constructor can initialize state variables), but their values can still change at that point. In case where they do not, the immutable can be replaced by a constant anyway.

@matheusaaguiar Speaking of immutables, please make sure you have a test case against #15989. I.e. one showing that immutables are rejected even if they end up being treated as pure by the compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants